home *** CD-ROM | disk | FTP | other *** search
- Path: qualcomm.com!not-for-mail
- From: drew@qualcomm.com (Drew Eckhardt)
- Newsgroups: comp.lang.c++
- Subject: Re: [Q]Virtualizing/Deriving
- Date: 13 Apr 1996 01:34:36 -0600
- Organization: QUALCOMM, Incorporated; San Diego, CA, USA
- Message-ID: <4knlec$lno@qualcomm.com>
- References: <40.91023.1613@channel1.com>
- NNTP-Posting-Host: littlebear.qualcomm.com
-
- In article <40.91023.1613@channel1.com>,
- Dspse Bedford <dspse.bedford@channel1.com> wrote:
- >I just started using C++ so bare with me.
- >
- >Lets say I have a base class, BASE, with lots and lots of operators and
- >member functions virtualized, like 10,000. Now I create 100 derived classes
- >with BASE as their parent. The first 99 derived classes use all of the
- >operators and member function which exist in BASE, of course, if they need
- >to redefine any they will. The last derived class does not use some of the
- >operators defined, lets say 2 out of 10,000. Now if I don't define these 2
- >operators, the compiler will go pick up the parent definition if a user of
- >the last derived class attempts to use any of these two operators.
- > What can I do such that the compiler will give an error to the user? I
- >do not want to create another base class if possible.
-
- You can declare the functions you don't want called as private, and fail
- to define them. Ie, given
-
- class foo : public base {
- public:
- // stuff
-
- private:
- void dont_call ();
- };
-
- a user will get an error message if he attempts to call dont_call
- (scope is resolved before overloading, so this will keep the user
- from getting at a dont_call function with _any_ type signature in
- the base class).
-
- --
- <a href="http://www.poohsticks.org/drew/">Home Page</a>
- Four boxes : soap, ballot, jury, ammo. | Work: drew@Qualcomm.COM
- Use in that order. | Play: drew@PoohSticks.ORG
-